#! /bin/bash
# filename : chrony-client_edit.sh

set -e

CHRONY_CONFIG='/etc/chrony.conf'

sed -ri "s/^\s*(pool|server)/#&/g" "${CHRONY_CONFIG}"

if [ -n "$1" ]; then
    echo "server ${1} iburst" |tee -a "${CHRONY_CONFIG}"
fi

systemctl restart chronyd.service

echo "chronyd status is : $(systemctl is-active chronyd.service)"
